<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<link href="${basePath}/static/css/Pigeonhole/Pigeonhole_list.css" rel="stylesheet" type="text/css">
<link href="${basePath}/static/css/list.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="${basePath}/static/publics/assets/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="${basePath}/static/js/util.js"></script>
<div class="list_NR">
	<div class="loc">
	    <h3>新增病案</h3>
	    <!-- <ul class="loc_loc">病案归档 > 数据补录
	    </ul> -->
	</div>
	<div class="list_con_table">
            <div class="search_table">
               <ul class="clearfix" style="margin-bottom:0;">
               	<form method="post" style="height:144px;" id="addForm" action="${basePath}/medrecord/newRedrecord">
                   <li class="Label_1" style="color: red;">姓名：</li>
                   <li class="Label_2"><input class="input_box" type="text"  name='name' id='name' value='' title=""/></li>
                   <li class="Label_1">身份证号：</li>
                   <li class="Label_2">
                   <input type="hidden" name="identityDocumentTypeId" value="1"/>
                   <input class="input_box" type="text"  name='idNumber' id='idNumber' value=''/></li>
                    <li class="Label_1">性别：&nbsp;</li>
                   <li class="Label_2">
                   <select name="sexId" style="width:95%;height:30px">
                   		<option value="">请选择性别</option>
                   		<c:forEach items="${basicInfo['sexes']}" var="sex">
                   			<option value="${sex.id}">${sex.name}</option>
                   		</c:forEach>
                   	</select>
                   <li class="Label_1">出生日期：&nbsp;</li>
                   <li class="Label_2"><input class="input_box" type="text"  onFocus="WdatePicker()"  name='birthday' id='' value='' /></li>
                   <li class="Label_1" style="color: red;">ID号：</li>
                    <li class="Label_2"><input class="input_box" type="text"  name="mrId" id='mrId' value='' title=""/></li>
                   <li class="Label_1">病案号：</li>
                   <li class="Label_2"><input class="input_box" type="text"  name='onlyId' id='onlyId' value='' /></li>
                   <li class="Label_1" style="color: red;">出院日期：</li>
                   <li class="Label_2"><input class="input_box" type="text" name='outHospitalDate' id='outHospitalDate' value='' onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" title="" /></li>
                   <li class="Label_1" style="color: red;">出院科室：</li>
                   <li class="Label_2">
                   	<select name="outDeptId" id="outDeptId" style="width:95%;height:30px" title="">
                   		<option value="">请选择科室：</option>
                   		<c:forEach items="${offices}" var="office">
                   			<option value="${office.id}">${office.name}</option>
                   		</c:forEach>
                   	</select>
                   </li>
                   <li class="Label_1" style="color: red;">离院方式：</li>
                   <li class="Label_2">
                   <select name="outHospitalTypeId" style="width:95%;height:30px" title="">
                   		<option value="">请选择离院方式</option>
                   		<c:forEach items="${basicInfo['outHospitalTypes']}" var="outHospitalType">
                   			<option value="${outHospitalType.id}">${outHospitalType.name}</option>
                   		</c:forEach>
                   	</select>
                   </li>
                   <li class="Label_5">
                       <a id="Add" onclick="addFormSubmit()">新增</a>
                       
                   </li>
                   </form>
               </ul>
           </div> 
         
       </div>
       
</div>

<script type="text/javascript">
	function addFormSubmit(){
	$("input,select").focus(function() {
			$("[title='']").each(function() {
				$("[title='']").removeClass("input_change");

			});
		});
		var num = 0;//变量为1时 数据为空
		var notNull = false;//变量为true时提交数据
		$("[title='']").each(function() { //遍历元素对象   
			if ($(this).val() == "") { //判断元素对象的value值  
				$(this).addClass("input_change"); //添加css样式  
				num = 1;
			} else {
				notNull = true;
			}
		});
		if (num == 1) {
			layer.alert("必选项不能为空!",{icon:7});
			//alert("必选项不能为空!");
			notNull = false;
			return;
		}
		if(notNull==true){
		 	var name=document.getElementById("name").value;
		 	if(name.length>12){
		 		layer.alert("姓名格式不正确或超出长度!",{icon:7});
		 		//alert("姓名格式不正确或超出长度");
		 		$("#name").addClass("input_change");
		 		$("#name").focus(function(){
					$(this).removeClass("input_change");
				});
		 		return;
		 	}
		 	var idNumber=$("#idNumber").val();
		 	var flag=validateIdCard(idNumber);
		 	if(flag==false){
		 		$("#idNumber").addClass("input_change");
		 		$("#idNumber").focus(function(){
					$(this).removeClass("input_change");
				});
		 		return;
		 	}
		$("#addForm").submit();
	}}
	
</script>